<!-- 设置 -->
<template>
	<view class="box-set-up">
		<u-cell-group :border="false">
			<u-cell-item title="收货地址" @click="goOpenAddressPage"><u-icon name="e618" slot="icon" size="34" color="#999" custom-prefix="iconfont"></u-icon></u-cell-item>
			<u-cell-item title="个人信息" @click="$to('/package/user/user-info/index')">
				<u-icon name="e66e" slot="icon" size="34" color="#999" custom-prefix="iconfont"></u-icon>
			</u-cell-item>
			<u-cell-item title="管理端" @click="$to('/package/system/login')" v-if="vuex_config.showAdmin">
				<u-icon name="e611" slot="icon" size="34" color="#999" custom-prefix="iconfont"></u-icon>
			</u-cell-item>
			<u-cell-item v-if="vuex_config.account_login == 1 && vuex_user.mobile" title="修改密码" @click="toUpdatePass()"><u-icon name="e6aa" slot="icon" size="34" color="#999" custom-prefix="iconfont"></u-icon></u-cell-item>
			<u-cell-item title="注销" @click="cancellation()"><u-icon name="e609" slot="icon" size="34" color="#999" custom-prefix="iconfont"></u-icon></u-cell-item>
			<!-- <navigator open-type="exit" target="miniProgram" class="navtor">
				<view style="color:#606266;text-align: center;width: 100%;">退出登录</view>
			</navigator> -->
			<!-- 			 -->
			<view class="navtor" @click="exitout()">
				<view style="color:#606266;text-align: center;width: 100%;">{{ str }}</view>
			</view>
		</u-cell-group>
	</view>
</template>

<script>
import { uniModal,openAddress } from '@/utils/uniPromise';
import { wxConfig } from '@/mixins/wxConfig';
export default {
	mixins:[wxConfig],
	data() {
		return {
			str: ''
		};
	},
	mounted() {
		// #ifndef H5
		this.str = '退出登录';
		// #endif
		// #ifdef H5
		// h5需要先获取支付和地址的配置
		this.initWxConfig(['openAddress'])
			.then(() => {})
			.catch(() => {});
		this.str = '重新登录';
		// #endif
	},
	methods: {
		// 编辑地址
		goOpenAddressPage() {
			openAddress()
		},
		exitout() {
			this.$u.vuex('vuex_user', {});
			this.$u.vuex('vuex_token', '');
			this.$u.vuex('vuex_adminuser', {});
			// #ifndef H5
			this.$linkTo('index');
			// #endif
			// #ifdef H5
			let str = window.location.origin + '/';
			window.location.replace(str);
			// #endif
		},
		toUpdatePass () {
			this.$linkTo('/package/common/updatePassword')
		},
		// 注销
		cancellation() {
			uni.showModal({
				content: '您将一键注销账户信息，包含订单和其他交易数据将删除，操作后无法再恢复，确定还要注销帐号？',
				success: res => {
					if (res.confirm) {
						this.$loading();
						this.$resPost('SetUserLogout').then(() => {
							this.$loading();
							this.exitout();
						});
					}
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.box-set-up {
	padding: 30rpx;

	/deep/.u-icon--right {
		margin-right: 15rpx !important;
	}
}

.navtor {
	display: flex;
	border-bottom: 1rpx solid rgba(228, 231, 237, 0.5);
	padding: 26rpx 32rpx;
}
</style>
